





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Submit a Pull Request &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/translations.js"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="next" title="Git 使用技巧" href="git_howto.html" />
    <link rel="prev" title="Error Handling Guide" href="error_handling.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html">
          

          
            
            <img src="../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../install/index.html">安装 TVM</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">贡献者指南</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="community.html">TVM社区指南</a></li>
<li class="toctree-l2"><a class="reference internal" href="code_review.html">执行代码审查</a></li>
<li class="toctree-l2"><a class="reference internal" href="committer_guide.html">Committer Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="document.html">Write Documentation for TVM</a></li>
<li class="toctree-l2"><a class="reference internal" href="code_guide.html">代码指南和提示</a></li>
<li class="toctree-l2"><a class="reference internal" href="error_handling.html">Error Handling Guide</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Submit a Pull Request</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#ci-environment">CI Environment</a></li>
<li class="toctree-l3"><a class="reference internal" href="#testing">Testing</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#c">C++</a></li>
<li class="toctree-l4"><a class="reference internal" href="#python">Python</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="git_howto.html">Git 使用技巧</a></li>
<li class="toctree-l2"><a class="reference internal" href="release_process.html">Apache TVM Release Process</a></li>
</ul>
</li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../reference/langref/index.html">语言参考</a></li>
<li class="toctree-l1"><a class="reference internal" href="../reference/api/python/index.html">Python API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../reference/api/links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../reference/publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="index.html">贡献者指南</a> <span class="br-arrow">></span></li>
        
      <li>Submit a Pull Request</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/contribute/pull_request.rst.txt" rel="nofollow"> <img src="../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="submit-a-pull-request">
<h1>Submit a Pull Request<a class="headerlink" href="#submit-a-pull-request" title="永久链接至标题">¶</a></h1>
<p>This is a quick guide to submit a pull request, please also refer to the detailed guidelines.</p>
<ul>
<li><p>Before submit, please rebase your code on the most recent version of main, you can do it by</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>git remote add upstream <span class="o">[</span>url to tvm repo<span class="o">]</span>
git fetch upstream
git rebase upstream/main
</pre></div>
</div>
</li>
<li><p>Make sure code style check pass by typing the following command, and all the existing test-cases pass.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># Run all lint steps.</span>
docker/lint.sh

<span class="c1"># To run steps individually, specify their step names on the command-line. An incorrectly</span>
<span class="c1"># spelled step name causes the tool to print all available steps.</span>
docker/lint.sh &lt;step_name&gt; ...

<span class="c1"># While the lint commands used should be identical to those run in CI, this command reproduces</span>
<span class="c1"># the CI lint procedure exactly (typically helpful for debugging lint script errors).</span>
docker/bash.sh ci_lint ./tests/scripts/task_lint.sh
</pre></div>
</div>
<p>When the clang-format lint check fails, run git-clang-format as follows to automatically reformat
your code:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># Run clang-format check for all the files that changed since upstream/main</span>
docker/bash.sh ci_lint ./tests/lint/git-clang-format.sh upstream/main
</pre></div>
</div>
</li>
<li><p>Add test-cases to cover the new features or bugfix the patch introduces.</p></li>
<li><p>Document the code you wrote, see more at <a class="reference internal" href="document.html#doc-guide"><span class="std std-ref">Write Documentation for TVM</span></a></p></li>
<li><p>Send the pull request and fix the problems reported by automatic checks.</p></li>
<li><p>Request code reviews from other contributors and improves your patch according to feedbacks.</p>
<ul class="simple">
<li><p>To get your code reviewed quickly, we encourage you to help review others’ code so they can do the favor in return.</p></li>
<li><p>Code review is a shepherding process that helps to improve contributor’s code quality.
We should treat it proactively, to improve the code as much as possible before the review.
We highly value patches that can get in without extensive reviews.</p></li>
<li><p>The detailed guidelines and summarizes useful lessons.</p></li>
</ul>
</li>
<li><p>The patch can be merged after the reviewers approve the pull request.</p></li>
</ul>
<div class="section" id="ci-environment">
<h2>CI Environment<a class="headerlink" href="#ci-environment" title="永久链接至标题">¶</a></h2>
<p>We use docker container to create stable CI environments
that can be deployed to multiple machines.
Because we want a relatively stable CI environment and make use of pre-cached image,
all of the CI images are built and maintained by committers.</p>
<p>Upgrade of CI images can cause problems and need fixes to accommodate the new env.
Here is the protocol to update CI image:</p>
<ul class="simple">
<li><p>Send PR to upgrade build script in the repo
- Can be done by a contributor, the following steps need committership.</p></li>
<li><p>Build the new docker image</p></li>
<li><p>Tag the docker image with a new version and push to tvmai</p></li>
<li><p>Update the version(most of the time increase the minor version) in the Jenkinsfile, send a PR.</p></li>
<li><p>Fix any issues wrt to the new image versions in the PR.</p></li>
<li><p>Merge the PR and now we are in new version.</p></li>
<li><p>Tag the new version as the latest.</p></li>
<li><p>Periodically cleanup the old versions on local workers</p></li>
</ul>
</div>
<div class="section" id="testing">
<h2>Testing<a class="headerlink" href="#testing" title="永久链接至标题">¶</a></h2>
<p>Even though we have hooks to run unit tests automatically for each pull request, it’s always recommended to run unit tests
locally beforehand to reduce reviewers’ burden and speedup review process.</p>
<p>Running the C++ tests requires installation of gtest, following the instructions in
<a class="reference internal" href="../install/from_source.html#install-from-source-cpp-tests"><span class="std std-ref">使用 C++ 测试</span></a></p>
<div class="section" id="c">
<h3>C++<a class="headerlink" href="#c" title="永久链接至标题">¶</a></h3>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># assume you are in tvm source root</span>
<span class="nv">TVM_ROOT</span><span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>

./tests/scripts/task_cpp_unittest.sh
</pre></div>
</div>
</div>
<div class="section" id="python">
<h3>Python<a class="headerlink" href="#python" title="永久链接至标题">¶</a></h3>
<p>必要的依赖：</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pip install --user pytest Cython synr
</pre></div>
</div>
<p>If you want to run all tests:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># build tvm</span>
make

./tests/scripts/task_python_unittest.sh
</pre></div>
</div>
<p>If you want to run a single test:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="c1"># build tvm</span>
make

<span class="c1"># let python know where to find tvm related libraries</span>
<span class="nb">export</span> <span class="nv">PYTHONPATH</span><span class="o">=</span>python
rm -rf python/tvm/*.pyc python/tvm/*/*.pyc python/tvm/*/*/*.pyc

<span class="nv">TVM_FFI</span><span class="o">=</span>ctypes python -m pytest -v tests/python/unittest/test_pass_storage_rewrite.py

<span class="c1"># Additionally if you want to run a single test, for example test_all_elemwise inside a file.</span>
<span class="nv">TVM_FFI</span><span class="o">=</span>ctypes python -m pytest -v -k <span class="s2">&quot;test_all_elemwise&quot;</span> tests/python/frontend/tflite/test_forward.py
</pre></div>
</div>
</div>
</div>
</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="git_howto.html" class="btn btn-neutral float-right" title="Git 使用技巧" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="error_handling.html" class="btn btn-neutral float-left" title="Error Handling Guide" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>